package awt;
import javax.swing.*;
import java.awt.*;

public class BorderLayoutTest {
    public static void main(String[] args) {
        JFrame f = new JFrame("测试窗口");
        // 设置布局为 BorderLayout
        f.setLayout(new BorderLayout());

        // 添加按钮到不同位置
        JButton southButton = new JButton("南");
        JButton northButton = new JButton("北");
        JButton centerButton = new JButton("中");
        JButton eastButton = new JButton("东");
        JButton westButton = new JButton("西");

        // 设置按钮字体，确保支持中文
        Font font = new Font("SimHei", Font.PLAIN, 14);
        southButton.setFont(font);
        northButton.setFont(font);
        centerButton.setFont(font);
        eastButton.setFont(font);
        westButton.setFont(font);

        // 添加按钮到窗口
        f.add(southButton, BorderLayout.SOUTH);
        f.add(northButton, BorderLayout.NORTH);
        f.add(centerButton, BorderLayout.CENTER);
        f.add(eastButton, BorderLayout.EAST);
        f.add(westButton, BorderLayout.WEST);

        // 自动调整窗口大小以适应组件
        f.pack();

        // 设置窗口关闭时退出程序
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        // 显示窗口
        f.setVisible(true);
    }
}
